<%--
  Created by IntelliJ IDEA.
  User: piress
  Date: 2017/5/23
  Time: 16:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- CSS -->
    <link rel="stylesheet" href="/css/reset.css">
    <link rel="stylesheet" href="/css/supersized.css">
    <link rel="stylesheet" href="/css/style.css">

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

</head>
<body>

<div class="page-container">
    <h1>登录</h1>
    <div class="forms">
        <div id="error" style="display:none" ></div>
        <input type="text" id="username" class="username" placeholder="用户名">
        <input type="password" id="password" class="password" placeholder="密码">
        <button id="submit">提交</button>
    </div>
    <div class="connect">
        <%--<p>Or connect with:</p>--%>
        <p>
            <%--<a class="facebook" href=""></a>--%>
            <%--<a class="twitter" href=""></a>--%>
        </p>
    </div>
</div>

<!-- Javascript -->
<script src="/js/jquery-1.8.2.min.js"></script>
<script src="/js/supersized.3.2.7.min.js"></script>
<script src="/js/supersized-init.js"></script>
<script src="/js/scripts.js"></script>
<script>
$(function(){

});

$("input").focus(function(){
    $("#error").text("");
    $("#error").hide();
});

$("#submit").click(function(){
    var username = $("#username").val();
    var password = $("#password").val();
    $.ajax({
        type : 'GET',
        url : '/tologin',
        data : {
            "username" : username,
            "password" : password
        },
        dataType : 'json',
        success : function(data) {
            if(data.code==200){
                window.location.href='/';
            }else{
                console.log(data.msg);
                $("#error").text(data.msg);
                $("#error").show();
            }
        }
    });
})
</script>
</body>
</html>
